//
//  AXMyActivityVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/13.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXMyActivityVC.h"
#import "UIViewController+HBD.h"
#import "AXMyActivitySpellVC.h"

@interface AXMyActivityVC ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic , strong) UITableView *tableview;

@end

@implementation AXMyActivityVC

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self creatView];
    [self setlayout];
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;
    [self setupNavigationItems];
    
  
}

- (void)creatView {
    
    self.tableview = [[UITableView alloc]init];
    self.tableview.tableFooterView = [UIView new];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.view addSubview:self.tableview];
    
    
}

- (void)setlayout {
    
    self.tableview.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, Hn)
    .widthIs(SCREEN_WIDTH)
    .heightIs(TableViewHeight);
    
    
}


- (void)setupNavigationItems {
    
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;
    
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    /** title */
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    titleLabel.text = @"我的活动";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = FONT_EIGHTEEN;
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    self.navigationItem.titleView = titleLabel;
    
}

- (void)backAction:(UIBarButtonItem *)item {
    
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - tableview delegate & tableviewdatasource


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        
        AXMyActivitySpellVC *vc = [[AXMyActivitySpellVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
        
        
    }else if (indexPath.row == 1) {
        
    }else if (indexPath.row == 2) {
        
    }
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

// 返回每个分区中显示的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   
    return 3;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if (cell != nil) {
        

        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH-40, 44)];
        label.text = @[@"拼单",@"拼团",@"预售"][indexPath.row];
        label.textColor = COLOR_GREEN;
        label.font = FONT_FOURTEEN;
        label.textAlignment = NSTextAlignmentLeft;
        [cell addSubview:label];
        
        
      
    }
  
    
    
    return cell;
}



@end
